package com.example.yiwei.crm.view.frament.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.yiwei.crm.R;
import com.example.yiwei.crm.data.GetActivity;
import com.example.yiwei.crm.entity.activityEntity;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

/**
 * Created by Administrator on 2017/4/18.
 */

public class baseFragment extends Fragment {
    private TextView txt_manager,txt_activity_time,txt_participation,txt_department;
    activityEntity activityEntity;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView=inflater.inflate(R.layout.fragment_detailed_activity_base,container,false);
        txt_activity_time= (TextView) rootView.findViewById(R.id.frm_activity_base_txt_activity_time);
        txt_manager= (TextView) rootView.findViewById(R.id.frm_activity_base_txt_manager);
        txt_participation= (TextView) rootView.findViewById(R.id.frm_activity_base_txt_participation);
        txt_department= (TextView) rootView.findViewById(R.id.frm_activity_base_txt_department);
        activityEntity= GetActivity.get();


        if  (activityEntity.getActivity_time() != null) {
            String STR=activityEntity.getActivity_time().replaceAll(" ","");

            boolean b = STR.matches("\\d{4}-\\d{2}-\\d{2}");
            if (b) {
                txt_activity_time.setText(activityEntity.getActivity_time());
            } else {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
                String activity_time = activityEntity.getActivity_time();
                long l = Long.parseLong(activity_time);
                Date date = new Date(l);
                String nTime = sdf.format(date);
                txt_activity_time.setText(nTime);
            }
        }
        txt_department.setText(activityEntity.getActivity_department());
        txt_participation.setText(activityEntity.getActivity_participation());
        txt_manager.setText(activityEntity.getActivity_manager());
        return rootView;
    }

}
